use std::env;
use std::path::PathBuf;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
    
    tonic_build::configure()
        .server_mod_attribute(".", "#[cfg(feature = \"server\")]")
        .client_mod_attribute(".", "#[cfg(feature = \"client\")]")
        .file_descriptor_set_path(out_dir.join("tms_descriptor.bin"))
        .compile_protos(&["proto/tms.proto"], &["proto"])?;
    Ok(())
}